package fire.and.near.challenger.facebook;

public class MessageBuilder {

	private static String startChallengeTemplate = 
			"Here's my challenge for you: %s ~~~ "
			+ "Hurry up, the challenge won't wait for you too long! %s";
	
	private static String completeChallengeTemplate = 
			"Your challenge was: %s ~~~ "
			+ "And here's my reply: %s ~~~ %s";
	
	private static String completeSelfChallenge =
			"%s ~~~ %s";
	
	private String challenge;
	private String answer;
	private String hashtag;
	private MessageType type;
	
	public MessageBuilder(String challenge, String answer, String hashtag, MessageType type) {
		this.challenge = challenge;
		this.answer = answer;
		this.hashtag = hashtag;
		this.type = type;
	}
	
	public String getChallenge() {
		return challenge;
	}
	public void setChallenge(String challenge) {
		this.challenge = challenge;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
	public String getHashtag() {
		return hashtag;
	}
	public void setHashtag(String hashtag) {
		this.hashtag = hashtag;
	}
	public MessageType getType() {
		return type;
	}
	public void setType(MessageType type) {
		this.type = type;
	}
	
	public String build() {
		
		StringBuilder result = new StringBuilder("");
		
		if (type == MessageType.StartChallenge) {
			result.append(String.format(startChallengeTemplate, challenge, hashtag));
		} else if (type == MessageType.CompleteChallenge) {
			result.append(String.format(completeChallengeTemplate, challenge, answer, hashtag));
		} else if (type == MessageType.SelfChallenge) {
			result.append(String.format(completeSelfChallenge, answer, hashtag));
		}
		
		return result.toString();
	}
	
}
